﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Data;
using System.Data.SqlClient;

/// <summary>
/// Summary description for AdminDAO
/// </summary>
public class AdminDAO
{
    ConnectionDB ConDB;
	public AdminDAO()
	{
        ConDB = new ConnectionDB();
	}

    public DataTable check_adminDAO(Admin admin)
    {
        string sql = "select UsernameA from T_ADMIN_DIAOC where UsernameA=@id and PasswordA=@pass";
        SqlParameter[] para = new SqlParameter[2];
        para[0] = new SqlParameter("@id", admin.Username.ToLower());
        para[1] = new SqlParameter("@pass", admin.Password);
        return ConDB.ExecuteQuery(sql, para);
    }

    public bool changpass(Admin admin)
    {
        string sql = "UPDATE T_ADMIN_DIAOC SET PasswordA=@pass where UsernameA=@id";
        SqlParameter[] para = new SqlParameter[2];
        para[0] = new SqlParameter("@id", admin.Username);
        para[1] = new SqlParameter("@pass", admin.Password);
        return ConDB.ExecuteNonQuery(sql, para);
    }
}